@include('admin.layout.bone_header')


<div class="layui-btn-container">

</div>

<table class="layui-hide" id="think-table" lay-filter="think-table"></table>


<script id="barDemo" type="text/html">
    @{{#  if(d.status ==0 ){ }}
        <a class="layui-btn layui-btn-xs" lay-event="audit_withwal">审核</a>
    @{{#  } }}
</script>

<script>

    layui.use('table', function () {
        let table = layui.table;
        UI.getPageTable(table, "{{route('admin.bills.bills')}}", [
            {field: 'bill_id', title: 'ID', width:80, sort: true,fixed: 'left'}
            ,{field: 'username',title:'用户昵称',width:90,templet:function (d){
                    return d['user_info']['nickname']
             }}
            ,{field: 'num',title:'数量',width:90}
            ,{field: 'title',title:'标题',width:200}
            ,{field: 'username',title:'卡号信息',width: 200,templet:function (d){
                    if(d['type'] != 3){
                        return '';
                    }
                    let data = JSON.parse(JSON.parse(d['json_data']));
                    return data['card_no'];
                }}
            ,{field: 'username',title:'开户行',templet:function (d){
                    if(d['type'] != 3){
                        return '';
                    }
                    let data = JSON.parse(JSON.parse(d['json_data']));
                    return data['card_kai'];
                }}
            ,{field: 'username',title:'姓名',templet:function (d){
                    if(d['type'] != 3){
                        return '';
                    }
                    let data = JSON.parse(JSON.parse(d['json_data']));
                    return data['name'];
                }}
            ,{field: 'username',title:'类型',width:100,templet:function (d){
                    let arr = ['','佣金','DF值','提现'];
                    if(d['type'] == 9998){
                        return '余额';
                    }else if(d['type'] == 9997){
                        return '扶持基金';
                    }
                    return arr[d['type']]
             }}
            ,{field: 'username',title:'状态',templet:function (d){
                    let arr = ['审核中','已通过','已拒绝'];
                    return arr[d['status']]
             }},{field: 'username',title:'状态',templet:function (d){
                    let arr = ['审核中','已通过','已拒绝'];
                    return arr[d['status']]
             }}
            ,{field: 'created_at',title:'订单创建时间',templet:function (d){
                    return layui.util.toDateString(parseInt(d['created_at'])*1000,'yyyy-MM-dd HH:mm:ss')
            }}
            ,{fixed: 'right',title:'操作', align:'center', toolbar: '#barDemo'}
        ]);

        table.on('tool(think-table)', function (obj) {
            let data = obj.data;
            if(obj.event == 'audit_withwal'){
                UI.openLayer("{{route('admin.bill.audit')}}?bill_id="+data['bill_id']);
            }
        });
        let $ = layui.$, active = {
            addCategory:function (){
                UI.openLayer("{{route('admin.category.add')}}");
            },
            reload:function (){
                let search_key = $('#search_key');
                //执行重载
                table.reload('think-table', {
                    page: {
                        curr: 1 //重新从第 1 页开始
                    }
                    ,where: {
                        'search_key':search_key.val(),
                    }
                });
            }
        };
        $('.layui-btn-container .layui-btn').on('click', function () {
            let type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });

        $('.search .layui-btn').on('click', function () {
            let type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });

    })


</script>


@include('admin.layout.bone_footer')
